<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    {include file="../tpl/header.html" /}
</head>
<body>
{include file="../tpl/menu.html" /}
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form" method="post" action="{:url('admin/admin/sysConfAdd')}">

            <div class="layui-form-item">
                <label for="name" class="layui-form-label">
                    <span class="x-red">*</span>名称
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="name" name="name" required="" lay-verify="required" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>简介名称
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label"><span class="x-red">*</span>类型</label>
                <div class="layui-input-block">
                    {foreach name="type_list" item="vo"}
                    <input type="radio" value="{$key}" name="type" lay-skin="primary" title="{$vo}" />
                    {/foreach}
                </div>
            </div>

            <div class="layui-form-item">
                <label for="key" class="layui-form-label">
                    <span class="x-red">*</span>key
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="key" name="key" required="" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>存入缓存的唯一的key,不区分大小写,系统默认转大写,添加后不允许修改,请不要与其他key冲突
                </div>
            </div>

            <div class="layui-form-item layui-form-text">
                <label for="value" class="layui-form-label">val</label>
                <div class="layui-input-block">
                    <textarea id="value" name="value" placeholder="支持字符串,json(arr,obj)等" class="layui-textarea"></textarea>
                </div>
            </div>

            <div class="layui-form-item layui-form-text">
                <label for="value" class="layui-form-label">简介</label>
                <div class="layui-input-block">
                    <textarea name="desc" placeholder="" class="layui-textarea"></textarea>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label"></label>
                <button class="layui-btn" lay-filter="add" lay-submit="">增加</button>
            </div>
        </form>
    </div>
</div>
<script>
    layui.use(['form', 'layer'],
        function() {
            $ = layui.jquery;
            var form = layui.form, layer = layui.layer;
            //监听提交
            form.on('submit(add)', function(data) {
                $.ajax({
                    type:'post',
                    data:data.field,
                    dataType:'json',
                    url:"{:url('admin/admin/sysConfAdd')}",
                    success:function (e) {
                        if(e.code === 1){
                            layer.msg(e.msg, {icon: 6,time: layer_msg_success_time},
                                function() {
                                    var index = parent.layer.getFrameIndex(window.name);
                                    parent.layer.close(index);
                                    parent.location.reload();
                                });
                        }else{
                            layer.msg(e.msg, {icon: 5,time: layer_msg_error_time});
                        }
                    }
                });
                //发异步，把数据提交给php
                return false;
            });
        });
</script>

</body>
</html>